﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Radiation.Common
{
    public class Logger
    {
        public static Logger _instance;

        public static void Init()
        {
            _instance = new Logger();
        }

        public static Logger Instance
        {
            get
            {
                return _instance;
            }
        }

        // dynamic part

        public Dictionary<string, LoggerContainer> m_logs;

        public LoggerContainer this[string name]
        {
            get
            {
                if (!m_logs.ContainsKey(name))
                {
                    lock (m_logs)
                    {
                        m_logs.Add(name, new LoggerContainer());
                    }
                }

                return m_logs[name];
            }
        }

        public string[] LogNames
        {
            get
            {
                string[] final;

                lock (m_logs)
                {
                    final = m_logs.Keys.ToArray<string>();                        
                }

                return final;
            }
        }

        public Logger()
        {
            m_logs = new Dictionary<string, LoggerContainer>();
        }
    }
}
